#include"process.h"
#include<stdio.h>
#include<time.h>
#include<unistd.h>
#include<stdlib.h>
typedef void(*flush_t)(double current,double total,double net);
const double total = 1024.0;//1024mb
const double once = 0.5;//0.5mb
const int mod = 20;
void Download(flush_t func)
{
   //模拟网络下载行为
   double current = 0.0;
   while(current < total)
   {
      int r = rand()%mod + 1;
      int speed_net = once*r;
      current+=speed_net;
      if(current >= total) current = total;
      func(current,total,speed_net);
      usleep(50000);
   }
   printf("\n");
}
int main()
{
  srand(time(NULL));
  Download(Flushprocess);
  Download(Flushprocess);
  Download(Flushprocess);
  Download(Flushprocess);
  return 0;
}
